<?php

// connect db
include_once ('db.inc.php');


// function validate
function validate(&$data)
{
	$data = trim($data);
	$data = strip_tags($data);
	$data = mysql_escape_string($data);	
}


if(isset($_POST['name']) && !empty($_POST['name']))
{
	$name = validate($_POST['name']);
	
	$sql = "insert into user (name) values ('$name')";
	$result = mysql_query($sql);
	
	if($result)
	{
		echo 1;
	}
}